package com.itheima.health.controller;

import com.itheima.health.dto.OrderDTO;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Order;
import com.itheima.health.service.OrderService;
import com.itheima.health.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * 预约控制器
 */
@RestController
@RequestMapping("/mobile/order")
@Slf4j
@Api(tags = "手机端订单接口")
public class MobileOrderController {


    @Autowired
    private OrderService orderService;

    /**
     * 提交订单
     * @param dto
     * @return
     */
    @PostMapping("/submit")
    @ApiOperation("提交订单")
    public Result submit(@RequestBody OrderDTO dto) throws ParseException {
        Order submit = orderService.submit(dto);
        return Result.success(submit);
    }

    @GetMapping("/findById")
    @ApiOperation("订单详情")
    public Result findById(@RequestParam Integer id){
        OrderVO orderVO = orderService.findById(id);
        return Result.success(orderVO);
    }
}
